import { defineComponent, watch, ref } from 'vue'
import * as echarts from 'echarts'
const chartDom = document.getElementById('main');
const myChart = echarts.init(chartDom);
let option;
// 声明类型
const PropsType = {
  cdata: {
    type: Object,
    require: true
  }
} as const
const gaugeData = [
  {
    value: 50,
    name: 'Perfect',
    title: {
      offsetCenter: ['0%', '-40%']
    },
    detail: {
      valueAnimation: true,
      offsetCenter: ['0%', '-20%']
    }
  }
];
option = {
  series: [
    {
      type: 'gauge',
      startAngle: 180,
      endAngle: 360,
      pointer: {
        show: false
      },
      progress: {
        show: true,
        overlap: false,
        roundCap: true,
        clip: false,
        itemStyle: {
          borderWidth: 1,
          borderColor: '#464646'
        }
      },
      axisLine: {
        lineStyle: {
          width: 40
        }
      },
      splitLine: {
        show: false,
        distance: 0,
        length: 10
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        show: false,
        distance: 50
      },
      data: gaugeData,
      title: {
        fontSize: 14
      },
      detail: {
        width: 50,
        height: 14,
        fontSize: 14,
        color: 'inherit',
        borderColor: 'inherit',
        borderRadius: 20,
        borderWidth: 1,
        formatter: '{value}%'
      }
    }
  ]
};
setInterval(function () {
  myChart.setOption({
    series: [
      {
        data: gaugeData,
        pointer: {
          show: false
        }
      }
    ]
  });
}, 2000);

option && myChart.setOption(option);
